#ifndef ROUTINGDIALOG_H
#define ROUTINGDIALOG_H

#include <QDialog>
#include <QList>
#include <QTimer>
#include "VRPObjects.h"
#include "OSRMRouter.h"

namespace Ui {
    class RoutingDialog;
}

enum {ColFrom = 0, ColTo = 1, ColDistance = 2,  ColStatus = 3};

class RoutingDialog : public QDialog
{
    Q_OBJECT

public:
    explicit RoutingDialog(const CustomerInfo& info,
                           const QList<CustomerPtr>& customerList,
                           DepoPtr depo,
                           QList< QPair<CustomerPtr, RouteType> >& routeList,
                           RouteType& depoRoute,
                           QWidget *parent = 0);
    ~RoutingDialog();

private slots:
    void processRoutingResult(int error);
    void breakRouting();
    void correctClose();

private:
    Ui::RoutingDialog *ui;

    const CustomerInfo& info_;
    const QList<CustomerPtr>& customerList_;
    DepoPtr depo_;

    QList< QPair<CustomerPtr, RouteType> >& routeList_;
    RouteType& depoRoute_;

    OSRMRouter* router_;

    bool isRoutingFailed_;
    int rowIndex_;
    QList<CustomerPtr>::const_iterator customerIterator_;

    void initCommonUi();
    void setTableRow(const QString& from, const QString& distance, const QString& status, int index);
    void finishRouting();
    void startRoutingToCustomer(CustomerPtr customer);

    LineStringPtr qPointFListToLineString(const QList<QPointF>& pointsF, QString from = QString(), QString to = QString());
};

#endif // ROUTINGDIALOG_H
